/**

 @Name：layuiAdmin 公共业务
 @Author：@@

 */

layui.define(function (exports) {
    var $ = layui.$
        , layer = layui.layer
        , laytpl = layui.laytpl
        , setter = layui.setter
        , view = layui.view
        , admin = layui.admin

    //公共业务的逻辑处理可以写在此处，切换任何页面都会执行
    //……


    //退出
    admin.events.logout = function () {
        // localStorage.setItem('layuiAdmin', '');
        // localStorage.removeItem('layuiAdmin')
        debugger;
        // var access_token = layui.data('layuiAdmin').Authorization
        // $.ajax(
        //     {
        //         url: layui.setter.loginAddr + "/auth/logout",
        //         async: false,    //表示请求是否异步处理
        //         type: "get",    //请求类型
        //         headers: {
        //             'Authorization': layui.data('layuiAdmin').Authorization,
        //         },
        //         // beforeSend: function (XMLHttpRequest) {
        //         //     XMLHttpRequest.setRequestHeader("Authorization", access_token);
        //         // },
        //         // dataType: "json",//返回的数据类型
        //         success: function (data) {
        //             debugger;
        //             layui.data('layuiAdmin', {
        //                 key: 'Authorization',
        //                 value: ''
        //             })
        //             window.location = layui.setter.logoutAddress
        //         },
        //         error: function (msg) {
        //             layer.msg('网络异常')
        //         }
        //     }
        // )
        window.location = layui.setter.loginAddr + "/auth/logout?access_token=" + layui.data('layuiAdmin').access_token
        layui.data('layuiAdmin', {
            key: 'Authorization',
            value: ''
        })
        // window.location = layui.setter.loginAddr + `/auth/logout?access_token=${layui.data('layuiAdmin').Authorization}`
        // window.location = layui.setter.loginAddr + "/auth/logout?access_token=" + access_token

        // href = 'http://10.0.23.97:8094/auth/oauth/authorize?response_type=token&client_id=client_1&redirect_uri=http://localhost:63342/XuChangFont/start/index.html?_ijt=r8gamlt0o96j6ai6l1hpsfut19#/home/home'
        // window.location.href = 'http://10.0.23.97:8094/auth/logout'


        //执行退出接口
        // admin.req({
        //     // url: './json/user/logout.js'
        //     url: 'http://10.0.23.97:8094/auth/oauth/authorize?response_type=token&client_id=client_1&redirect_uri=http://localhost:63342/XuChangFont/start/index.html?_ijt=r8gamlt0o96j6ai6l1hpsfut19#/home/home'
        //     , type: 'get'
        //     , data: {}
        //     , done: function (res) { //这里要说明一下：done 是只有 response 的 code 正常才会执行。而 succese 则是只要 http 为 200 就会执行
        //
        //         //清空本地记录的 token，并跳转到登入页
        //         admin.exit();
        //     }
        // });
    };
    //对外暴露的接口
    exports('common', {});
});